﻿<UserControl 
    x:Class="ViewSwitchingNavigation.Contacts.Views.ContactsView"  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:model="clr-namespace:ViewSwitchingNavigation.Contacts.Model"
    xmlns:viewmodel="clr-namespace:ViewSwitchingNavigation.Contacts.ViewModels"
    xmlns:prism="http://www.codeplex.com/prism"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400" >

    <UserControl.Resources>
        <DataTemplate x:Key="ContactListTemplate">
            <StackPanel Orientation="Vertical">
                <TextBlock Text="{Binding Name}"/>
                <TextBlock Text="{Binding EmailAddress}" Margin="10,0,0,0" Foreground="#FF525252" />
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White">

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <ListBox ItemsSource="{Binding Contacts}" 
                 ItemTemplate="{StaticResource ContactListTemplate}" 
                 Grid.Column="0" Grid.RowSpan="2" AutomationProperties.AutomationId="ContactsList"/>

        <GridSplitter Grid.Column="1" HorizontalAlignment="Left" Grid.RowSpan="2"/>

        <Button Command="{Binding EmailContactCommand}"
                Grid.Column="1" Grid.Row="0" Margin="10,0,0,5" HorizontalAlignment="Left">
            Email
        </Button>

        <ScrollViewer Grid.Column="1" Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
                      Margin="10,0,0,0">
            <ContentControl prism:RegionManager.RegionName="ContactDetailsRegion" DataContext="{Binding Contacts.CurrentItem}" />
        </ScrollViewer>


    </Grid>
</UserControl>
